//
//  YHContributeTitleItem.m
//  Catches
//
//  Created by jiangqiong on 2018/5/17.
//  Copyright © 2018年 solot. All rights reserved.
//

#import "YHContributeTitleItem.h"

@implementation YHContributeTitleItem

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.selectedColor = [UIColor blackColor];
        self.normalColor = [UIColor whiteColor];
        [self configLayout];
        [self setupGestureRecognizer];
    }
    return self;
}

- (void)configLayout {
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(@0);
        make.centerY.equalTo(self.mas_centerY).offset(10);
        
    }];
}


- (void)setupGestureRecognizer {
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(touchUpInside:)];
    [self addGestureRecognizer:tap];
}

- (void)touchUpInside:(id)sender {
    if ([self.delegate respondsToSelector:@selector(didPressedMenuItem:)]) {
        [self.delegate didPressedMenuItem:self];
    }
}


#pragma mark override

- (void)setSelected:(BOOL)selected withAnimation:(BOOL)animation {
    [super setSelected:selected withAnimation:animation];
#pragma mark 颜色修改
    if (selected) {
        self.titleLabel.textColor = [UIColor blackColor];
    } else {
        self.titleLabel.textColor = [UIColor grayColor];
    }
}



@end
